package com.gitee.wsl.struct.command.testing

import com.gitee.wsl.struct.command.context.Context
import com.gitee.wsl.struct.command.context.sources.MapValueSource
import com.gitee.wsl.struct.command.context.sources.ValueSource
import com.gitee.wsl.struct.command.model.parameters.options.Option
import com.gitee.wsl.test.shouldBe
import com.gitee.wsl.test.withClue


class TestSource(vararg values: Pair<String, String>) : ValueSource {
    private var read: Boolean = false
    private val source = MapValueSource(values.toMap())

    override fun getValues(context: Context, option: Option): List<ValueSource.Invocation> {
        read = true
        return source.getValues(context, option)
    }

    fun assert(read: Boolean) {
        withClue("ValueSource read") {
            this.read shouldBe read
        }
    }
}
